<html lang="en">
<head>
    @include('Admin.header')
    <script type="text/javascript" src="{{ URL::asset('My97DatePicker/WdatePicker.js') }}?v={{$version}}" charset="utf-8"></script>
</head>
<body>
@component('Admin.section.title')
@endcomponent
<div class="wrapper">
    @include('Admin.menu')
    <div class="page-content">
        <div class="content">
            <form class="layui-form xbs" action="">
                <div class="layui-form-pane" style="text-align: center;">
                    <div class="layui-form-item" style="display: inline-block;">
                        <label class="layui-form-label xbs768">日期范围</label>
                        <div class="layui-input-inline xbs768">
                            <input id="d411" class="layui-input" type="text" name="start_time" value="{{$start_time}}" placeholder="开始日"  onclick="WdatePicker({minDate:'2017-01-01',maxDate:'%y-%M-%d'})"/>
                        </div>
                        <div class="layui-input-inline xbs768">
                            <input id="d4312" class="layui-input" type="text" name="end_time" value="{{$end_time}}"   placeholder="截止日" onclick="WdatePicker({minDate:'#F{$dp.$D(\'d411\')}',maxDate:'%y-%M-%d'})"/>
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" name="username" placeholder="请输入用户名" value="{{$username}}" autocomplete="off"
                                   class="layui-input">
                        </div>
                        <div class="layui-input-inline" style="width:80px">
                            <button class="layui-btn" lay-submit="" lay-filter="sreach"><i
                                    class="layui-icon">&#xe615;</i></button>
                        </div>
                    </div>
                </div>
            </form>
            <xblock>
                <button class="layui-btn layui-btn-danger" onclick="delAll('{{csrf_token()}}')"><i class="layui-icon">&#xe640;</i>批量删除
                </button>
                <button class="layui-btn"
                        onclick="_add('添加用户','{{url('Admin/System/administrator/add')}}','600','500')"><i
                        class="layui-icon">&#xe608;</i>添加
                </button>
                <span class="x-right" style="line-height:40px">共有数据：{{count($list)}} 条</span></xblock>
            <table class="layui-table">
                <thead>
                <tr>
                    <th>
                        <input type="checkbox" name="" value="1">
                    </th>
                    <th>
                        ID
                    </th>
                    <th>
                        昵称
                    </th>
                    <th>
                        账号
                    </th>
                    <th>
                        角色
                    </th>
                    <th>
                        加入时间
                    </th>
                    <th>
                        状态
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
                </thead>
                <tbody>
                @foreach ($list as $vo)
                <tr class="tr_{{$vo->id}}">
                    <td>
                        <input type="checkbox" value="{{ $vo->id }}" name="check">
                    </td>
                    <td>
                        {{ $vo->id }}
                    </td>
                    <td>
                        {{ $vo->nickname }}
                    </td>
                    <td>
                        {{$vo->account}}
                    </td>
                    <td>
                        {{ $vo->r_name }}
                    </td>
                    <td>
                        {{$vo->created_at}}
                    </td>
                    <td class="td-status">
                        @if(1 == $vo->status)
                        <span class="layui-btn layui-btn-normal layui-btn-mini">
                                已启用
                            </span>
                        @else
                        <span class="layui-btn layui-btn-disabled layui-btn-mini">已停用</span>
                        @endif
                    </td>
                    <td class="td-manage">
                        @if(1 == $vo->status)
                        <a style="text-decoration:none" onclick="_status_stop(this,'{{url('Admin/System/administrator/status')}}','{{$vo->id}}','{{csrf_token()}}')" href="javascript:;" title="停用">
                            <i class="layui-icon">&#x1006;</i>
                        </a>
                        @else
                        <a style="text-decoration:none" onClick="_status_start(this,'{{url('Admin/System/administrator/status')}}','{{$vo->id}}','{{csrf_token()}}')" href="javascript:;" title="启用"><i class="layui-icon">&#xe605;</i></a>
                        @endif
                        &nbsp;
                        <a title="编辑" href="javascript:;" onclick="_edit('编辑','{{url('Admin/System/administrator/edit')}}/{{$vo->id}}','600','500')" class="ml-5" style="text-decoration:none">
                            <i class="layui-icon">&#xe642;</i>
                        </a>
                        &nbsp;
                        <a title="删除" href="javascript:;" onclick="_del(this,'{{url('Admin/System/administrator/del')}}','{{$vo->id}}','{{csrf_token()}}')" style="text-decoration:none">
                            <i class="layui-icon">&#xe640;</i>
                        </a>
                    </td>
                </tr>
                @endforeach
                </tbody>
            </table>
        </div>
    </div>
</div>
@component('Admin.section.bg')
@endcomponent
<script>
    //批量删除提交
    var arr = [];
    function delAll(token) {
        layer.confirm('确认要删除吗？', function (index) {
            $('input:checkbox[name=check]:checked').each(function(i){
                arr[i] = $(this).val();
            });
            $.ajax({
                dataType:'json',
                type:'post',
                url:"{{url('Admin/System/administrator/del')}}",
                data:{id:arr,_token:token},
                success:function(data){
                    if(1 === data){
                        for(var s in arr){
                            $(".tr_"+arr[s]).remove();
                        }
                        layer.msg('已删除!',{icon:1,time:1000});
                    }
                }
            });
        });
    }
</script>
</body>
</html>